// https://blog.csdn.net/xsm_656/article/details/122024385
function ListNode(val, next) {
  this.val = val === undefined ? 0 : val;
  this.next = next === undefined ? null : next;
}
var swapPairs = function (head) {
  let vnode = new ListNode(-1, head);
  let pre = vnode;
  while (pre.next && pre.next.next) {
    // 缓存相应值
    let cur = pre.next;
    let last = pre.next.next;
    // 交换
    cur.next = last.next;
    last.next = cur;

    // 下面类似计数作用
    pre.next = last;
    pre = cur;
  }
  return vnode.next;
};

// https://juejin.cn/post/7031734271387631629
